// 主脚本
package script

import (
	"fmt"
	"log"
	"mhxyLw/lwsoft"
	"time"
)

func script() {

}

// 创建lw对象
func NewLw() {
	//初始化com组件，多线程的
	lwsoft.CoInitializeEx()
	//	创建新的lw对象
	gLw, err := lwsoft.New()
	if err != nil {
		log.Println("lwsoft.New()", err)
	}
	defer lwsoft.CoUninitialize()
	defer gLw.Release()

	fmt.Println("主函数内", gLw.GetID())
	for i := 0; i < 5; i++ {
		go run(i)
	}

	time.Sleep(time.Second)
}
func run(i int) {
	lw, err := lwsoft.New()
	if err != nil {
		log.Println("lwsoft.New()", err)
	}
	defer lw.Release()
	fmt.Printf("第%d个go内id为%d\n", i, lw.GetID())
}
